﻿using System;
using System.Windows.Input;
using DevComponents.WPF.Controls;
using Microsoft.Practices.Prism.Commands;

namespace ZhiHeng.OneCard.WpfClient.ViewModel
{
    public class LoginViewModel : ViewModelBase
    {
        private MainViewModel _MainViewModel;
        public LoginViewModel()
        {
            _MainViewModel = MainViewModel.Instance;
        }

        public object AllUsers { get { return _MainViewModel.Users; } }

        private UserViewModel _CurrentUser;
        public UserViewModel CurrentUser
        {
            get { return _CurrentUser; }
            set { SetPropertyValue(value, ref _CurrentUser, "CurrentUser"); }
        }

        private DelegateCommand _NavigateBackCommand;
        public DelegateCommand NavigateBackCommand
        {
            get
            {
                if (_NavigateBackCommand == null)
                    _NavigateBackCommand = new DelegateCommand(() => CurrentUser = null,() => CurrentUser != null);
                return _NavigateBackCommand;
            }
        }
    }
}
